package main;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Date;
import java.util.Scanner;

import metier.*;

public class App {

	private Stock stock ;
	private Date date_debut; 

	
	public App() throws IOException {
		
		//Init stock vide
	//	this.stock = new Stock();
		
		int ent_sauc_sec = 0;
		int ent_sauc_sec_noix = 0;
		boolean quit = false;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			
		
		
		while (quit != true)
		{
		System.out.println("\n\nVeuillez saisir la date de début de simulation \n");
		System.out.print("Année : ");
		String year = br.readLine();
		
		System.out.print("Mois : ");
		String month = br.readLine();
		
		System.out.print("Jour : ");
		String day = br.readLine();
		
		this.date_debut = new Date(Integer.valueOf(year), Integer.valueOf(month), Integer.valueOf(day));
					
		System.out.println("Génération du stock .....");
		//Init stock remplis
		Stock.delInstance();
		this.stock = Stock.getInstance();
		this.stock.affichage_stock(this.date_debut);

		System.out.println("\n\nVeuillez saisir les prévisions de ventes mensuelles \n");
		System.out.print("Saucisson sec : ");
		String sauc_sec_vente = br.readLine();
		Vente.getInstance().setPrev_vente_sauc_sec(Integer.valueOf(sauc_sec_vente));
		
		System.out.print("Saucisson sec aux noix :");
		String sauc_sec_noix_vente = br.readLine();
		Vente.getInstance().setPrev_vente_sauc_sec_n(Integer.valueOf(sauc_sec_noix_vente));
		
		System.out.println("\n\nVeuillez saisir les quantités à produire \n");
		System.out.print("Saucisson sec : ");
		String sauc_sec = br.readLine();
		
		System.out.print("Saucisson sec aux noix :");
		String sauc_sec_noix = br.readLine();
		
		
		//Production prod = new Production(new Date(2011, 1, 1), new Date(2011, 2, 1), 1);
		Production prod2 = new Production(this.date_debut, Integer.valueOf(sauc_sec), 1, Integer.valueOf(sauc_sec_noix), 2);
		String choix = null;
		do{
		System.out.println("\n\nRefaire une simulation ? Y / N");
		 choix = br.readLine();
		}while(choix.compareTo("Y") != 0 && choix.compareTo("N") != 0);
		
		if (choix.compareTo("N") == 0)
			quit = true;		
		
		}
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		System.out.println("********Merci d'avoir utilisé Sauc'prod !*********");
		
	}
	
	
	
	
	
	
	
	public static void main(String[] args) {

		System.out.println("********Bienvenue dans Sauc'prod !*********");
		
		try {
			App monApp = new App();
		} catch (IOException e) {
			// TODO Auto-generated catch block
		}	
		
	}

}
